package dk.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.ReturnData.ResponseData;
import com.netflix.client.http.HttpRequest;

import dk.service.ApiService;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("UploadApi")
public class UploadController {
	@Autowired
	ApiService apiservice;
	@PostMapping("UploadSubjectImgById")
	@ApiOperation("根据id上传图片")
	public ResponseData  UploadSubjectImgById(HttpServletRequest request,MultipartFile file) {
		System.out.println(file.getName());
		Integer id = Integer.valueOf(request.getHeader("id"));
		return apiservice.UploadSubjectImgById(id,file);
	}
	@PostMapping("CreateOptionExampleExcel")
	@ApiOperation("创建单选模板并返回链接")
	public ResponseData CreateOptionExampleExcel() {
		return apiservice.CreateOptionExampleExcel();
	}
	@PostMapping("GetOptionExamListByExcel")
	@ApiOperation("上传excel数据解析单选数据并返回")
	public ResponseData GetOptionExamListByExcel(MultipartFile file) {
		return apiservice.GetOptionExamListByExcel(file);
	}
	@PostMapping("CreateShortAnswerExamlist")
	@ApiOperation("创建简答模板并返回链接")
	public ResponseData CreateShortAnswerExamlist() {
		return apiservice.CreateShortAnswerExamlist();
	}
	@PostMapping("GetShortAnswerExamListByExcel")
	@ApiOperation("上传excel数据解析单选数据并返回")
	public ResponseData GetShortAnswerExamListByExcel(MultipartFile file) {
		return apiservice.GetShortAnswerExamListByExcel(file);
	}
}
